package epin.fujiajun.sort.merge;

import epin.fujiajun.data.Array;
import epin.fujiajun.data.array.Number;

/**
 * Created by DELL on 2017/8/29.
 */
public class DownToTop extends Original {

    @Override
    public void sort(Array[] a) {
        int N = a.length;
        super.aux = new Array[N];

        for (int size = 1; size < N;size = size + size){
            for (int index = 0;index < N - size;index += size + size){
                super.merge(a, index, index + size - 1, Math.min(index + size + size -1, N - 1));
            }
        }
    }

    public static void main(String[] args){
        new DownToTop().main(Number.createArray(100, 1000));
    }

}
